<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://www.tietiao.com/functions" prefix="my"%>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>个人主页</title>
<!--[if lt IE 9]>
		<script src="/_ui/js/html5.js"></script>
	<![endif]-->
<!--[if lte IE 7]>
		<link rel="stylesheet" type="text/css" media="all" href="../css/feground/ie.css" />
	<![endif]-->
<%@ include file="../include/include.jsp"%>
<script type="text/javascript" src="./js/fg/common/utils.js"></script>
<script type="text/javascript" src="./js/lazyload/lazyload_src.js"></script>
<script type="text/javascript" src="./js/fg/user/relation.js"></script>
<script>
// 异步加载关注我 
function loadAttentionMe(pageIndex){
	$(".userList li").removeClass("li-selected");
	$("#attenMeFried").addClass("li-selected");
	$("#content").html("正在载入数据....");
	$.post("friend_friends_attentionMeList.htm",{userId:$("#hidenuserId").val()},function(data) {
		$("#content").html(data);
	});
};
// 异步加载我关注的朋友
function loadMeAttention(pageIndex,group){
	$(".userList li").removeClass("li-selected");
	$("#meAttenFriend").addClass("li-selected");
	$("#content").html("正在载入数据....");
	$.post("friend_friends_meAttentionList.htm",{userId: $("#hidenuserId").val(),groupId:group},function(data) {
		$("#content").html(data);
	});
};
// 异步加载图片数据 
function attentionComm(url,lableId,obj){
	$("#hidenurl").val(url);
	$("#hidenlableId").val(lableId);
	$(".userList li").removeClass("li-selected");
	if(obj!=null && obj=='likeMyComn'){
		$("#likeMyComn").addClass("li-selected");
	}else{
		$("#myComn").addClass("li-selected");
	}
	postURL();
}
//  排序 
function sortComm(orderBy,obj){
	$(".wrapper-content-title .sort").removeClass("sortselected");
	$(obj).addClass("sortselected");
	$("#hidenorderBy").val(orderBy);
	postURL();
}

function attenLable(name,obj){
	$("#hidenname").val(name);
	$("#hidenurl").val("friend_friends_favorite.htm");
	if(obj!=null){
		$(".user-tag .tag").removeClass("selected");
		$(obj).addClass("selected");
	}
	postURL();
};
// 查询我关注标签
function postURL(){
	$("#groupAreaId").html("正在载入数据....");
	$('#pageNo').attr('value',1);
	$.ajax({
	   type: "POST",
	   dataType:'HTML',
	   url: $("#hidenurl").val()+"?"+$("#formId").serialize(),
	   success:function(data){
	   		$("#content").html(data);
			$("#content img").lazyload({effect:"fadeIn"} );

			if('friend_friends_commodity.htm' == $("#hidenurl").val()) {
				var len = $('#browse_size').val();
				var pageSize = $('#pageSize').val();
				if (len == pageSize) {
					$('#browse_size').remove();
					$('#pageNo').attr('value',new Number($('#pageNo').val()) + 1);
					$('#content').append('<div class="pagination" id="browse_nextpage'+ $('#pageNo').val()+ '"><span class="loading" >正在加载数据...</span></a></div>');
					postUrlNext();
				}
			}
	   }
	});
};

function postUrlNext() {
	$("#browse_nextpage" +$('#pageNo').val()).each(function() {
		$(this).one("appear", function() {
			$.ajax({
				type : "POST",
				dataType : 'html',
				cache : false,
				url : $("#hidenurl").val()+"?"+$("#formId").serialize(),
				success : function(data) {
					$("#content").append('<div id="nextpage'+$('#pageNo').val() + '" >' + data+ '</div>');
					$("#browse_nextpage" +$('#pageNo').val()).remove();
					$('#nextpage' +$('#pageNo').val() + ' img').lazyload({effect : "fadeIn"});
					var len = $('#browse_size').val();
					if (len == $('#pageSize').val()) {
						$('#browse_size').remove();
						$('#pageNo').attr('value',new Number($('#pageNo').val()) + 1);
						$('#content').append('<div class="pagination" id="browse_nextpage'
										+$('#pageNo').val()
										+ '"><span class="loading" >正在加载数据...</span></a></div>');
						postUrlNext();
					}
				}
			});
		});
	});

	$(window).bind("scroll", function(event) {
		$("#browse_nextpage" + $('#pageNo').val()).each(function() {
			if ($(window).height() + $(window).scrollTop() > $(this).offset().top) {
				$(this).trigger("appear");
			}
		});
	});
};

// 查询我的收藏
function postCommodity(){
	$("#content").html("正在载入数据....");
	$.ajax({
	   type: "POST",
	   dataType:'HTML',
	   url: "friend_friends_commodity.htm?"+$("#formId").serialize(),
	   success:function(data){
	   		$("#content").html(data);
			$("#content img").lazyload({effect:"fadeIn"} );
			
	   }
	});
}

order = function(orderSortId) {
	if (orderSortId == 'hot_sort_id') {
		$('#time_sort_id').removeClass('sortselected');
		$('#time_sort_id').removeClass('ascending');
		if ($('#' + orderSortId).hasClass('sortselected')) {
			if ($('#' + orderSortId).hasClass('ascending')) {
				$('#hidenorderBy').attr('value','TIETIAO_NUM DESC');
				$('#' + orderSortId).removeClass('ascending');
			} else {
				$('#hidenorderBy').attr('value','TIETIAO_NUM ASC');
				$('#' + orderSortId).addClass('ascending');
			}
		} else {
			$('#' + orderSortId).addClass('sortselected');
			$('#hidenorderBy').attr('value','TIETIAO_NUM DESC');
			$('#' + orderSortId).removeClass('ascending');
		}
	} else {
		$('#hot_sort_id').removeClass('sortselected');
		$('#hot_sort_id').removeClass('ascending');
		if ($('#' + orderSortId).hasClass('sortselected')) {
			if ($('#' + orderSortId).hasClass('ascending')) {
				$('#hidenorderBy').attr('value','UPLOADER_TIME DESC');
				$('#' + orderSortId).removeClass('ascending');
			} else {
				$('#hidenorderBy').attr('value','UPLOADER_TIME ASC');
				$('#' + orderSortId).addClass('ascending');
			}
		} else {
			$('#' + orderSortId).addClass('sortselected');
			$('#hidenorderBy').attr('value','UPLOADER_TIME DESC');
			$('#' + orderSortId).removeClass('ascending');
		}
	}
	postURL();
};
</script>
</head>
<body class="wider no-subnav catalog-lists" style="overflow: inherit;">
	<c:import url="../include/default_head.jsp" />
	<div class="container">
		<div class="wrapper-content left-sidebar">
		<div id="content"></div>
		<div class="user-section" id="sidebar">
			<table width="100%" cellspacing="0" cellpadding="0" border="0">
				<tbody>
					<tr>
						<td valign="top"><img class="photo" alt="" src="${photoPath}/${sysUser.userPhoto}"></td>
						<td valign="top">${sysUser.petName}<br><fmt:formatDate value="${sysUser.createTime}" pattern="yy年MM月"/>加入<br>长居：${sysUser.province}<br></td>
					</tr>
				</tbody>
			</table>
			<ul class="userList">
				<li id="myComn">
					<a class="share-icon" href="#" onclick="attentionComm('friend_friends_commodity.htm','-1','myComn')" onfocus="this.blur();">${userId==user.userId? '我':'Ta'}的分享(${myFavorite})</a>
				</li>
				<li id="meAttenFriend" class="li-selected">
					<a class="vote-icon" href="#" onclick="loadMeAttention('0','-1');" onfocus="this.blur();">${userId==user.userId? '我':'Ta'}的关注(${meAttenFried})</a>
					<em>爱</em>
				</li>
				<li id="likeMyComn">
					<a class="votes-icon" href="#" onclick="attentionComm('friend_friends_likeMyComm.htm','-1','likeMyComn')" onfocus="this.blur();">收到贴条(${favoriteByOther})</a>
				</li>
				<li id="attenMeFried">
					<a class="fans-icon" href="#" onclick="loadAttentionMe('0');return false;" onfocus="this.blur();">${userId==user.userId? '我':'Ta'}的粉丝(${attenMeFried})</a>
				</li>
			</ul>
		</div>
	</div>
	<c:import url="../include/default_foot.jsp" />
</div>
	<form action="" id="formId" method="post">
		<input id="hidenuserId" value="${userId}" type="hidden" name="userId">
		<input id="hidenurl" value="${url}" type="hidden" name="url">
		<input id="hidenlableId" value="${lableId}" type="hidden" name="lableId">
		<input id="hidenorderBy" value="TIETIAO_NUM DESC" type="hidden" name="orderBy">
		<input id="hidenpageIndex" value="${pageIndex}" type="hidden" name="pageIndex">
		<input id="hidenname" value="${lableName}" type="hidden" name="name">
		<input id="pageNo" value="1"  type="hidden" name="pageNo">
		<input id="pageSize" value="60" type="hidden" name="pageSize">
	</form>
	<script type="text/javascript">
		loadMeAttention('0','-1');
	</script>
</body>
</html>